package com.li.design;  
/**  
* 类说明   
*  
* @author ****  
* @date 2018年4月1日  新建  
*/
public class RespChain {
	static abstract class MyLogger{
		private int INFO  = 1;
		private int DEBUG = 2;
		private int ERROR = 3;
		
		MyLogger myLogger;
		public void setMyMyLogger(MyLogger myLogger){
			this.myLogger = myLogger;
		}
		abstract void printLog(int logLevel,String info);
	}
	
	static class InfoLogger extends MyLogger{
		@Override
		void printLog(int logLevel, String info) {
			// TODO Auto-generated method stub
			if(logLevel == 1){
				System.out.println("info  "+info);
			}
			if(myLogger!=null)
			myLogger.printLog(logLevel, info);
		}
	}
	
	static class DebugLogger extends MyLogger{
		@Override
		void printLog(int logLevel, String info) {
			// TODO Auto-generated method stub
			if(logLevel == 2){
				System.out.println("debug  "+info);
			}
			if(myLogger!=null)
			myLogger.printLog(logLevel, info);
		}
	}
	
	static class ErrorLogger extends MyLogger{
		@Override
		void printLog(int logLevel, String info) {
			// TODO Auto-generated method stub
			if(logLevel == 3){
				System.out.println("error  "+info);
			}
			if(myLogger!=null)
			myLogger.printLog(logLevel, info);
		}
	}
	
	public static void main(String[] args) {
		MyLogger il = new InfoLogger();
		MyLogger dl = new DebugLogger();
		MyLogger el = new ErrorLogger();
		il.setMyMyLogger(dl);
		dl.setMyMyLogger(el);
		
		il.printLog(2, "it is a debug message");
	}
}
  